
local function CreateTestFrame(title)
	local frame = CreateFrame("Frame", nil, UIParent)
	frame:SetBackdrop({
		bgFile = "Interface\\TutorialFrame\\TutorialFrameBackground",
		edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
		tile = true, edgeSize = 16, tileSize = 32,
		insets = { left = 5, right = 5, top = 5, bottom = 5 }
	})

	frame:SetToplevel()
	frame:EnableMouse(true)
	frame:SetMovable(true)
	frame:RegisterForDrag"LeftButtonUp"

	local title = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightLarge")
	frame.title = title
	title:SetPoint("TOP", 0, -12)
	title:SetText(title)

	frame:SetSize(256, 256)
	frame:SetPoint"CENTER"

	frame:Show()
	frame:SetScript("OnMouseDown", function(self) self:StartMoving() end)
	frame:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end)

	return frame
end

local CreateTexture = function (parent, path, blend)
	local t = parent:CreateTexture(nil, "ARTWORK")
	t:SetSize(32, 32)
	t:SetAllPoints()
	t:SetTexture(path)
	if blend then
		t:SetBlendMode(blend)
	end
	return t
end

local function CreateButton(parent, title, handler)
	local button = CreateFrame("Button", nil, parent)

	button:SetNormalFontObject(GameFontNormal)
	button:SetHighlightFontObject(GameFontHighlight)
	button:SetDisabledFontObject(GameFontDisable)
	button:SetText(title)

	button:SetNormalTexture(CreateTexture(button, "Interface\\Buttons\\UI-Panel-Button-Up"))
	button:SetPushedTexture(CreateTexture(button, "Interface\\Buttons\\UI-Panel-Button-Down"))
	button:SetDisabledTexture(CreateTexture(button, "Interface\\Buttons\\UI-Panel-Button-Disabled"))
	button:SetHighlightTexture(CreateTexture(button, "Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight", "ADD"))

	button:SetSize(96, 32)
	if handler then button:SetScript("OnClick", handler) end

	return button
end


local function CheckAnimationInitialisation()
	local frame = CreateTestFrame("Animation")

	local sparkle = frame:CreateTexture(nil, "ARTWORK")
	sparkle:SetTexture"Interface\\ItemSocketingFrame\\UI-ItemSockets"
	sparkle:SetTexCoord(0.3984375, 0.4453125, 0.40234375, 0.44921875)
	sparkle:SetPoint"TOPLEFT"
	sparkle:SetBlendMode"ADD"
	sparkle:SetSize(64, 64)

	local animGroup = sparkle:CreateAnimationGroup()
	animGroup:SetLooping"REPEAT"
	local translation = animGroup:CreateAnimation"Translation"
	translation:SetStartDelay(0)
	translation:SetEndDelay(0)
	translation:SetDuration(5)
	translation:SetSmoothing"IN_OUT"
	translation:SetOrder(1)
	translation:SetMaxFramerate(30)
	translation:SetOffset(256, -256)
--~ 	animGroup:Play()

	frame:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() animGroup:Play() end)

end

local function CheckButtonState()
	local frame = CreateTestFrame("Button")

	local b = CreateButton(frame, "Sample")
	b:SetPoint("TOP", 0, -32)
	frame.button = b

	b = CreateButton(frame, "Enable", function (self) self:GetParent().button:Enable() end)
	b:SetPoint("TOPLEFT", 12, -64)

	b = CreateButton(frame, "Disable", function (self) self:GetParent().button:Disable() end)
	b:SetPoint("TOPLEFT", 12, -100)

	b = CreateButton(frame, "Lock", function (self) self:GetParent().button:SetButtonState("PUSHED", true) end)
	b:SetPoint("TOPRIGHT", -12, -64)

	b = CreateButton(frame, "Unlock", function (self) self:GetParent().button:SetButtonState("NORMAL") end)
	b:SetPoint("TOPRIGHT", -12, -100)
end

local function CheckTexture()
	local frame = CreateTestFrame"Texture"

	local t = frame:CreateTexture()
	t:SetTexture"Interface\\AddOns\\Talented\\Textures\\branches-normal"
	t:SetPoint("TOP", 0, -32)
	t:SetSize(256, 32)
	frame.texture = t

	local b = CreateButton(frame, "SetVertexColor", function (self)
		self:GetParent().texture:SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b)
	end)
	b:SetPoint("TOP", 0, -64)

	local b = CreateButton(frame, "Reset Texture", function (self)
		local t = self:GetParent().texture
		t:SetTexture(nil)
		t:SetVertexColor(1, 1, 1)
		t:SetTexture"Interface\\AddOns\\Talented\\Textures\\branches-normal"
	end)
	b:SetPoint("TOP", 0, -100)

end

--~ CheckAnimationInitialisation()
--~ CheckButtonState()
--~ CheckTexture()
